---
to: src/global-models/<%= name.replace(/_/g, '') %>/index.ts
condition: <%= model %>
---


import { createSlice } from '@reduxjs/toolkit';

export const createScoreSlice = (params: { score?: number; order?: number }) => {
  const { score, order } = params;
  const slice = createSlice({
    name: '<%= name.replace(/_/g, '') %>Slice',
    initialState: {
      score: 0,
      order: 1 
    },
    reducers: {
      setScore: (state, action) => {
        return {
          ...state,
          score: action.payload,
        };
      },
      setOrder: (state, action) => {
        return {
          ...state,
          order: action.payload,
        };
      },
    },
  });
  return slice;
};
